import pytest,logging
from config.sql import sql
from config.Base import Base
import pymysql,requests
class Test_wdds():
    sql=''
    hed=''
    id=''
    def setup_class(self):
        self.min='http://10.59.9.18'
        logging.error('用例执行时执行')
        self.a=Base()
    def teardown_class(self):
        print('用例执行结束')
        logging.warning('用例执行后执行')
    @pytest.mark.skip
    def test_001(self):
        url=self.min+'/small/user/v1/login'
        body={"phone":"15649920321","pwd":"ycy20040102"}
        logging.warning('第一条测试用例')
        c=self.a.post(url,json=body)

        print(c.json())
    def test_002(self):
        url='http://10.59.9.12:7001/api/public/login'
        body={"username":"15649920322","password":"123456"}
        c=self.a.post(url,json=body)
        print(c.json())
    def test_003(self):
        url='http://10.59.9.12:7001/api/goods/view?id=37'
        ac=self.a.get(url,headers=self.hed)
        print(ac.json())
    def test_004(self):
        url='http://10.59.9.12:7001/api/cart/add'
        body={"id":37,"sku_id":"","num":1}
        ac=self.a.post(url,headers=Test_wdds.hed,json=body)
        print(ac.json())
    def test_005(self):
        url='http://10.59.9.12:7001/api/cart?page=1'
        ac=self.a.get(url=url,headers=Test_wdds.hed)
        Test_wdds.id=ac.json()['data']['list'][0]['id']
        print(ac.json())
    def test_006(self):
        url=f'http://10.59.9.12:7001/api/order/confirm?id={Test_wdds.id}&type=cart&shipping_type=1'
        ac=self.a.get(url,headers=Test_wdds.hed)
        print(ac.json())
    def test_007(self):
        url='http://10.59.9.12:7001/api/order/create'
        body={"id":Test_wdds.id,"type":"cart","address_id":101,"store_id":1,"shipping_type":1,"bonus_id":"0","payment":"balance","remarks":"","source":1,"url":"http://10.59.9.12:7001/wap/pages/cart/confirm?id=1586&type=cart"}
        ac=self.a.post(url,json=body,headers=Test_wdds.hed)
        print(ac.json())
if __name__ == '__main__':
    pytest.main()